<!DOCTYPE html>
<html>
<head>
    <title>数据 - FinData</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            font-family: 'Arial', sans-serif;
            background-color: #0a0a0a;
            color: #e0e0e0;
        }
        .header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 15px 30px;
            background-color: #121212;
            border-bottom: 1px solid #333;
        }
        .logo-container {
            display: flex;
            align-items: center;
        }
        .logo {
            width: 40px;
            height: 40px;
            margin-right: 10px;
            filter: drop-shadow(0 0 5px rgba(138, 43, 226, 0.7));
            animation: pulse 2s infinite alternate;
        }
        .logo-text {
            font-size: 24px;
            font-weight: bold;
            background: linear-gradient(90deg, #8a2be2, #a855f7, #c084fc);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            text-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
            animation: shine 3s linear infinite;
            margin-right: auto;
            padding-left: 15px;
        }
        .nav-container {
            display: flex;
            gap: 20px;
        }
        .nav-item {
            position: relative;
            padding: 10px 20px;
            background: linear-gradient(145deg, #1e1e1e, #2a2a2a);
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
            color: #e0e0e0;
            text-decoration: none;
            overflow: hidden;
            z-index: 1;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .nav-item::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(45deg, #8a2be2, #00bfff);
            z-index: -1;
            opacity: 0;
            transition: opacity 0.3s ease;
        }
        .nav-item:hover {
            transform: translateY(-3px);
            box-shadow: 0 6px 12px rgba(138, 43, 226, 0.3);
            color: white;
        }
        .nav-item:hover::before {
            opacity: 1;
        }
        .nav-item::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 50%;
            width: 0;
            height: 3px;
            background: #4CAF50;
            transition: all 0.3s ease;
        }
        .nav-item:hover::after {
            width: 70%;
            left: 15%;
        }
        .nav-item.active {
            background: linear-gradient(45deg, #8a2be2, #00bfff);
            color: white;
            box-shadow: 0 6px 12px rgba(138, 43, 226, 0.5);
        }
        
        /* 主体内容样式 */
        .container {
            max-width: 1200px;
            margin: 30px auto;
            padding: 0 20px;
        }
        
        .page-title {
            text-align: center;
            margin-bottom: 40px;
        }
        
        .page-title h1 {
            font-size: 36px;
            margin-bottom: 10px;
            background: linear-gradient(90deg, #8a2be2, #00bfff);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            display: inline-block;
        }
        
        .page-title p {
            font-size: 18px;
            color: #aaa;
        }
        
        .data-section {
            background: linear-gradient(145deg, #121212, #1a1a1a);
            border-radius: 15px;
            padding: 30px;
            margin-bottom: 40px;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
            position: relative;
            overflow: hidden;
            border-left: 5px solid;
            animation: fadeIn 0.8s ease forwards;
        }
        
        .data-section::before {
            content: '';
            position: absolute;
            top: -50%;
            right: -50%;
            width: 200px;
            height: 200px;
            background: radial-gradient(circle, rgba(255, 255, 255, 0.03) 0%, transparent 70%);
            border-radius: 50%;
            opacity: 0.5;
        }
        
        .stock-data {
            border-left-color: #4CAF50;
        }
        
        .index-data {
            border-left-color: #00bfff;
        }
        
        .financial-data {
            border-left-color: #8a2be2;
        }
        
        .section-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 25px;
            padding-bottom: 15px;
            border-bottom: 1px solid #333;
        }
        
        .section-title {
            font-size: 24px;
            font-weight: bold;
            display: flex;
            align-items: center;
        }
        
        .stock-data .section-title {
            color: #4CAF50;
        }
        
        .index-data .section-title {
            color: #00bfff;
        }
        
        .financial-data .section-title {
            color: #8a2be2;
        }
        
        .section-title i {
            margin-right: 12px;
            font-size: 28px;
        }
        
        .download-btn {
            padding: 12px 24px;
            background: linear-gradient(45deg, #8a2be2, #a855f7);
            color: white;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-weight: bold;
            position: relative;
            overflow: hidden;
            box-shadow: 0 4px 15px rgba(138, 43, 226, 0.3);
            z-index: 1;
            display: flex;
            align-items: center;
        }
        
        .download-btn i {
            margin-right: 8px;
        }
        
        .download-btn::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
            transition: all 0.5s ease;
            z-index: -1;
        }
        
        .download-btn:hover {
            transform: translateY(-3px);
            box-shadow: 0 7px 20px rgba(138, 43, 226, 0.5);
        }
        
        .download-btn:hover::before {
            left: 100%;
        }
        
        .stock-data .download-btn {
            background: linear-gradient(45deg, #4CAF50, #8BC34A);
        }
        
        .stock-data .download-btn:hover {
            box-shadow: 0 7px 20px rgba(76, 175, 80, 0.5);
        }
        
        .index-data .download-btn {
            background: linear-gradient(45deg, #00bfff, #1E88E5);
        }
        
        .index-data .download-btn:hover {
            box-shadow: 0 7px 20px rgba(0, 191, 255, 0.5);
        }
        
        .section-content {
            display: flex;
            justify-content: space-between;
            gap: 30px;
        }
        
        .data-info {
            flex: 1;
        }
        
        .data-description {
            margin-bottom: 20px;
            line-height: 1.6;
            color: #ccc;
        }
        
        .data-fields {
            background-color: rgba(0, 0, 0, 0.2);
            border-radius: 8px;
            padding: 15px;
            margin-bottom: 20px;
        }
        
        .data-fields h4 {
            margin-top: 0;
            margin-bottom: 10px;
            color: #e0e0e0;
            font-size: 16px;
        }
        
        .field-list {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
            gap: 10px;
            margin-top: 10px;
        }
        
        .field-item {
            background-color: #f5f5f5;
            padding: 6px 12px;
            border-radius: 4px;
            font-size: 0.9rem;
            color: #333;
            position: relative;
            cursor: help;
        }
        
        .field-item:hover::after {
            content: attr(title);
            position: absolute;
            left: 0;
            top: 100%;
            background-color: #333;
            color: #fff;
            padding: 5px 10px;
            border-radius: 4px;
            font-size: 0.8rem;
            white-space: nowrap;
            z-index: 100;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
        }
        
        .stock-data .field-item {
            border-left: 3px solid #4CAF50;
        }
        
        .index-data .field-item {
            border-left: 3px solid #00bfff;
        }
        
        .financial-data .field-item {
            border-left: 3px solid #8a2be2;
        }
        
        .data-sample {
            flex: 1;
            background-color: #0d0d0d;
            border-radius: 8px;
            padding: 20px;
            overflow: auto;
            max-height: 300px;
            box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
            border: 1px solid #333;
        }
        
        .data-sample pre {
            margin: 0;
            font-family: 'Consolas', monospace;
            font-size: 14px;
            color: #aaa;
            line-height: 1.5;
        }
        
        .data-sample-title {
            margin-top: 0;
            margin-bottom: 15px;
            color: #e0e0e0;
            font-size: 16px;
            text-align: center;
        }
        
        .data-note {
            font-size: 0.85rem;
            color: #888;
            padding: 12px 18px;
            background-color: #222228;
            border-top: 1px solid #333;
        }
        
        .data-note i {
            margin-right: 5px;
            color: #4fc3f7;
        }
        
        /* 登录提示模态框样式 */
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.7);
            z-index: 1000;
            justify-content: center;
            align-items: center;
        }
        
        .modal-content {
            background-color: #1a1a1a;
            border-radius: 10px;
            padding: 30px;
            width: 400px;
            text-align: center;
            box-shadow: 0 0 20px rgba(138, 43, 226, 0.5);
            position: relative;
        }
        
        .modal-icon {
            margin-bottom: 20px;
        }
        
        .modal-title {
            font-size: 20px;
            margin-bottom: 10px;
            color: #e0e0e0;
        }
        
        .modal-message {
            color: #aaa;
            margin-bottom: 20px;
        }
        
        .modal-buttons {
            display: flex;
            justify-content: center;
            gap: 10px;
        }
        
        .modal-btn {
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.3s;
            font-weight: bold;
        }
        
        .cancel-btn {
            background-color: #333;
            color: #e0e0e0;
        }
        
        .cancel-btn:hover {
            background-color: #444;
        }
        
        .login-btn {
            background-color: #8a2be2;
            color: white;
        }
        
        .login-btn:hover {
            background-color: #7928a1;
        }
        
        .login-btn:active {
            transform: scale(0.95);
        }
        
        .close-btn {
            position: absolute;
            top: 10px;
            right: 15px;
            font-size: 24px;
            color: #aaa;
            cursor: pointer;
            transition: all 0.3s;
        }
        
        .close-btn:hover {
            color: white;
        }
        
        /* 动画 */
        @keyframes pulse {
            0% {
                transform: scale(1);
                opacity: 0.8;
            }
            100% {
                transform: scale(1.1);
                opacity: 1;
                filter: drop-shadow(0 0 10px rgba(138, 43, 226, 0.9));
            }
        }
        
        @keyframes shine {
            to {
                background-position: 200% center;
            }
        }
        
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }
        
        /* 响应式设计 */
        @media (max-width: 768px) {
            .section-content {
                flex-direction: column;
            }
            
            .section-header {
                flex-direction: column;
                gap: 15px;
                align-items: flex-start;
            }
            
            .data-sample {
                max-height: 200px;
            }
        }
        
        /* 免责声明和版权信息样式 */
        .disclaimer-container {
            background-color: rgba(18, 18, 18, 0.8);
            border-radius: 8px;
            padding: 15px;
            margin: 30px auto;
            max-width: 1200px;
            border-top: 1px solid #333;
        }
        
        .disclaimer-text {
            font-size: 12px;
            color: #888;
            text-align: center;
            line-height: 1.5;
            margin-bottom: 10px;
        }
        
        .copyright {
            font-size: 12px;
            color: #666;
            text-align: center;
            margin-top: 10px;
        }
        
        /* 表格容器样式优化 */
        .table-responsive {
            overflow-x: auto; /* 允许横向滚动 */
            overflow-y: hidden; /* 禁用垂直滚动 */
            margin-bottom: 20px;
            border: 1px solid #333;
            border-radius: 8px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
            background-color: #1a1a1a;
            width: 100%;
            padding-bottom: 5px; /* 为滚动条留出空间 */
        }
        
        /* 表格样式 */
        .data-table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 0;
            font-size: 0.9rem;
            color: #e0e0e0;
            background-color: #1a1a1a;
            border: none;
        }
        
        /* 设置表格列宽 */
        .data-table th, .data-table td {
            min-width: 100px; /* 设置最小宽度 */
            padding: 12px 15px;
            text-align: left;
            border: 1px solid #333;
            font-size: 0.9rem;
            white-space: nowrap; /* 防止文本换行 */
        }
        
        .data-table th {
            background: linear-gradient(to bottom, #2c2c38, #252532);
            font-weight: bold;
            color: #fff;
            text-transform: uppercase;
            font-size: 0.85rem;
            letter-spacing: 0.5px;
            border-bottom: 2px solid #4fc3f7;
        }
        
        .data-table tbody tr:nth-child(odd) {
            background-color: #1e1e26;
        }
        
        .data-table tbody tr:nth-child(even) {
            background-color: #222228;
        }
        
        .data-table tbody tr:hover {
            background-color: #2a2a36;
        }
        
        /* 数字右对齐 */
        .data-table td:nth-child(n+4) {
            text-align: right;
            font-family: 'Consolas', monospace;
        }
        
        /* 设置不同表格的主题色 */
        .stock-data .data-table th {
            border-bottom: 2px solid #4CAF50;
        }
        
        .index-data .data-table th {
            border-bottom: 2px solid #00bfff;
        }
        
        .financial-data .data-table th {
            border-bottom: 2px solid #8a2be2;
        }
        
        /* 数据样例容器 */
        .data-sample {
            margin-bottom: 30px;
            border-radius: 8px;
            overflow: hidden;
            background-color: #1a1a1a;
            border: 1px solid #333;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
            transition: all 0.3s ease;
        }
        
        .data-sample:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
        }
        
        .stock-data .data-sample-title {
            background: linear-gradient(to right, #1e3b1e, #2c3c2c);
            border-bottom: 2px solid #4CAF50;
        }
        
        .index-data .data-sample-title {
            background: linear-gradient(to right, #1a3a5a, #2c3c4c);
            border-bottom: 2px solid #00bfff;
        }
        
        .financial-data .data-sample-title {
            background: linear-gradient(to right, #3a1a4a, #3c2c4c);
            border-bottom: 2px solid #8a2be2;
        }
        
        .data-sample-title {
            color: #fff;
            padding: 15px 20px;
            margin: 0;
            font-size: 1.1rem;
            font-weight: bold;
            letter-spacing: 0.5px;
        }
        
        .data-sample-description {
            margin: 0;
            padding: 12px 20px;
            color: #aaa;
            font-size: 0.9rem;
            font-style: italic;
            text-align: center;
            background-color: #222228;
            border-bottom: 1px solid #333;
        }
        
        .data-note {
            font-size: 0.85rem;
            color: #888;
            padding: 12px 20px;
            background-color: #1e1e26;
            border-top: 1px solid #333;
        }
        
        .data-note i {
            margin-right: 8px;
            color: #4fc3f7;
        }
        
        /* 数字格式化样式 */
        .number-large {
            color: #4fc3f7;
            font-weight: 500;
        }
        
        /* 下载模态框样式 */
        .download-modal {
            max-width: 500px;
            background: linear-gradient(145deg, #1a1a24, #222230);
            border: 1px solid #444;
        }
        
        .download-icon path {
            stroke: #4fc3f7;
            stroke-width: 2;
        }
        
        .download-icon {
            background: radial-gradient(circle, rgba(79, 195, 247, 0.2) 0%, rgba(79, 195, 247, 0.1) 50%, transparent 70%);
            border-radius: 50%;
            padding: 15px;
            margin-bottom: 10px;
            animation: pulse-blue 2s infinite;
        }
        
        @keyframes pulse-blue {
            0% {
                box-shadow: 0 0 0 0 rgba(79, 195, 247, 0.4);
            }
            70% {
                box-shadow: 0 0 0 10px rgba(79, 195, 247, 0);
            }
            100% {
                box-shadow: 0 0 0 0 rgba(79, 195, 247, 0);
            }
        }
        
        .download-info {
            margin: 20px 0;
            width: 100%;
            background-color: rgba(0, 0, 0, 0.2);
            border-radius: 8px;
            padding: 15px;
        }
        
        .download-filename {
            font-weight: bold;
            margin-bottom: 20px;
            color: #e0e0e0;
            text-align: center;
            font-size: 1.1rem;
            padding: 10px;
            background-color: rgba(0, 0, 0, 0.2);
            border-radius: 4px;
            border-left: 4px solid #4fc3f7;
        }
        
        .download-link-container, .download-code-container {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
            flex-wrap: wrap;
        }
        
        .download-link-container p, .download-code-container p {
            margin: 0;
            margin-right: 10px;
            min-width: 100px;
            color: #aaa;
            font-weight: bold;
        }
        
        .link-input-group, .code-input-group {
            display: flex;
            flex: 1;
        }
        
        .download-link {
            flex: 1;
            padding: 10px 15px;
            border: 1px solid #444;
            background-color: #1a1a1a;
            color: #4fc3f7;
            border-radius: 4px 0 0 4px;
            font-family: 'Consolas', monospace;
            font-size: 0.9rem;
            border-right: none;
        }
        
        .extract-code {
            width: 80px;
            padding: 10px 15px;
            border: 1px solid #444;
            background-color: #1a1a1a;
            color: #4fc3f7;
            border-radius: 4px 0 0 4px;
            font-family: 'Consolas', monospace;
            text-align: center;
            font-size: 1rem;
            font-weight: bold;
            letter-spacing: 2px;
            border-right: none;
        }
        
        .copy-btn {
            padding: 10px 15px;
            background-color: #333;
            color: #e0e0e0;
            border: 1px solid #444;
            border-radius: 0 4px 4px 0;
            cursor: pointer;
            transition: all 0.3s;
            white-space: nowrap;
        }
        
        .copy-btn:hover {
            background-color: #444;
        }
        
        .copy-btn i {
            margin-right: 5px;
        }
        
        .download-btn-modal {
            background: linear-gradient(to right, #4fc3f7, #29b6f6);
            color: #111;
            font-weight: bold;
            padding: 12px 20px;
            border-radius: 4px;
            transition: all 0.3s;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        
        .download-btn-modal:hover {
            background: linear-gradient(to right, #29b6f6, #03a9f4);
            transform: translateY(-2px);
            box-shadow: 0 6px 10px rgba(0, 0, 0, 0.2);
        }
        
        .download-btn-modal i {
            margin-right: 8px;
        }
    </style>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
</head>
<body>
    <div class="header">
        <div class="logo-container">
            <svg class="logo" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg">
                <path d="M20 0 L40 20 L20 40 L0 20 Z" fill="#8a2be2"/>
                <path d="M10 10 L30 10 L30 30 L10 30 Z" fill="#00bfff"/>
                <path d="M15 15 L25 15 L25 25 L15 25 Z" fill="#4CAF50"/>
            </svg>
            <div class="logo-text">FinData</div>
        </div>
        
        <div class="nav-container">
            <a class="nav-item" href="/blank" id="homeNav">首页</a>
            <a class="nav-item" href="/favorites" id="favoritesNav">自选</a>
            <a class="nav-item" href="/data" id="dataNav">数据</a>
            <a class="nav-item" href="javascript:void(0)" onclick="checkLoginForBacktest()" id="backtestNav">回测</a>
            <a class="nav-item" href="/forum" id="forumNav">论坛</a>
            <a class="nav-item" href="/login" id="loginNav">登录</a>
            <a class="nav-item" style="display: none;" href="/dashboard" id="dashboardNav">个人中心</a>
        </div>
    </div>

    <div class="container">
        <div class="page-title">
            <h1>FinData 数据中心</h1>
            <p>提供高质量金融数据，助力您的投资决策</p>
        </div>
        
        <!-- 股票历史日线数据 -->
        <div class="data-section stock-data">
            <div class="section-header">
                <div class="section-title">
                    <i class="fas fa-chart-line"></i> 股票历史日线数据
                </div>
                <button class="download-btn">
                    <i class="fas fa-download"></i> 下载数据
                </button>
            </div>
            
            <div class="section-content">
                <div class="data-info">
                    <div class="data-description">
                        提供A股市场全部股票的历史日线交易数据，包括开盘价、收盘价、最高价、最低价、成交量等关键指标，数据更新至最近交易日。
                    </div>
                    
                    <div class="data-fields">
                        <h4>数据字段说明：</h4>
                        <div class="field-list">
                            <div class="field-item" title="股票代码">股票代码</div>
                            <div class="field-item" title="股票名称">股票名称</div>
                            <div class="field-item" title="交易日期">交易日期</div>
                            <div class="field-item" title="开盘价">开盘价</div>
                            <div class="field-item" title="最高价">最高价</div>
                            <div class="field-item" title="最低价">最低价</div>
                            <div class="field-item" title="收盘价">收盘价</div>
                            <div class="field-item" title="前收盘价">前收盘价</div>
                            <div class="field-item" title="成交量(股)">成交量(股)</div>
                            <div class="field-item" title="成交额(元)">成交额(元)</div>
                            <div class="field-item" title="流通市值">流通市值</div>
                            <div class="field-item" title="总市值">总市值</div>
                        </div>
                    </div>
                    
                    <div class="data-note">
                        <i class="fas fa-info-circle"></i> 数据为CSV格式，GBK编码
                    </div>
                </div>
                
                <div class="data-sample">
                    <h4 class="data-sample-title">数据样例</h4>
                    <div class="data-sample-description">
                        以下为浦发银行(600000)1999年11月部分交易日数据
                    </div>
                    <div class="table-responsive">
                        <table class="data-table">
                            <thead>
                                <tr>
                                    <th>股票代码</th>
                                    <th>股票名称</th>
                                    <th>交易日期</th>
                                    <th>开盘价</th>
                                    <th>最高价</th>
                                    <th>最低价</th>
                                    <th>收盘价</th>
                                    <th>前收盘价</th>
                                    <th>成交量</th>
                                    <th>成交金额</th>
                                    <th>涨跌幅(%)</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>600000</td>
                                    <td>浦发银行</td>
                                    <td>1999-11-10</td>
                                    <td>29.50</td>
                                    <td>29.80</td>
                                    <td>27.00</td>
                                    <td>27.75</td>
                                    <td>29.50</td>
                                    <td>164,167</td>
                                    <td>46,872,000</td>
                                    <td>-5.93</td>
                                </tr>
                                <tr>
                                    <td>600000</td>
                                    <td>浦发银行</td>
                                    <td>1999-11-11</td>
                                    <td>27.50</td>
                                    <td>27.67</td>
                                    <td>26.00</td>
                                    <td>26.00</td>
                                    <td>27.75</td>
                                    <td>68,420</td>
                                    <td>18,266,000</td>
                                    <td>-6.31</td>
                                </tr>
                                <tr>
                                    <td>600000</td>
                                    <td>浦发银行</td>
                                    <td>1999-11-12</td>
                                    <td>26.00</td>
                                    <td>26.00</td>
                                    <td>24.50</td>
                                    <td>24.99</td>
                                    <td>26.00</td>
                                    <td>98,630</td>
                                    <td>24,463,000</td>
                                    <td>-3.88</td>
                                </tr>
                                <tr>
                                    <td>600000</td>
                                    <td>浦发银行</td>
                                    <td>1999-11-15</td>
                                    <td>24.90</td>
                                    <td>25.50</td>
                                    <td>24.00</td>
                                    <td>24.90</td>
                                    <td>24.99</td>
                                    <td>53,020</td>
                                    <td>13,084,000</td>
                                    <td>-0.36</td>
                                </tr>
                                <tr>
                                    <td>600000</td>
                                    <td>浦发银行</td>
                                    <td>1999-11-16</td>
                                    <td>24.80</td>
                                    <td>25.43</td>
                                    <td>24.80</td>
                                    <td>25.20</td>
                                    <td>24.90</td>
                                    <td>33,557</td>
                                    <td>8,461,000</td>
                                    <td>1.20</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="data-note">
                        <i class="fas fa-info-circle"></i> 数据格式为CSV，编码为GBK。
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 主要指数历史日线数据 -->
        <div class="data-section index-data">
            <div class="section-header">
                <div class="section-title">
                    <i class="fas fa-chart-bar"></i> 主要指数历史日线数据
                </div>
                <button class="download-btn">
                    <i class="fas fa-download"></i> 下载数据
                </button>
            </div>
            
            <div class="section-content">
                <div class="data-info">
                    <div class="data-description">
                        提供上证指数、深证成指、创业板指、沪深300等主要指数的历史日线数据，包含指数点位、涨跌幅、成交量等关键指标，数据更新至最近交易日。
                    </div>
                    
                    <div class="data-fields">
                        <h4>数据字段说明：</h4>
                        <div class="field-list">
                            <div class="field-item" title="k线时间">candle_end_time</div>
                            <div class="field-item" title="开盘价">open</div>
                            <div class="field-item" title="最高价">high</div>
                            <div class="field-item" title="最低价">low</div>
                            <div class="field-item" title="收盘价">close</div>
                            <div class="field-item" title="成交额(元)">amount</div>
                            <div class="field-item" title="成交量(股)">volume</div>
                            <div class="field-item" title="指数代码">index_code</div>
                        </div>
                    </div>
                    
                    <div class="data-note">
                        <i class="fas fa-info-circle"></i> 数据为CSV格式，GBK编码
                    </div>
                </div>
                
                <div class="data-sample">
                    <h4 class="data-sample-title">数据样例</h4>
                    <div class="data-sample-description">
                        以下为上证指数(000001)2023年6月部分交易日数据
                    </div>
                    <div class="table-responsive">
                        <table class="data-table">
                            <thead>
                                <tr>
                                    <th>指数代码</th>
                                    <th>日期</th>
                                    <th>开盘价</th>
                                    <th>最高价</th>
                                    <th>最低价</th>
                                    <th>收盘价</th>
                                    <th>成交量(股)</th>
                                    <th>成交额(元)</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>000001</td>
                                    <td>2023-06-01</td>
                                    <td>3204.32</td>
                                    <td>3223.94</td>
                                    <td>3195.15</td>
                                    <td>3204.56</td>
                                    <td>24,589,534,400</td>
                                    <td>286,132,456,789</td>
                                </tr>
                                <tr>
                                    <td>000001</td>
                                    <td>2023-06-02</td>
                                    <td>3206.23</td>
                                    <td>3214.85</td>
                                    <td>3185.21</td>
                                    <td>3203.25</td>
                                    <td>23,458,967,200</td>
                                    <td>273,456,789,012</td>
                                </tr>
                                <tr>
                                    <td>000001</td>
                                    <td>2023-06-05</td>
                                    <td>3201.45</td>
                                    <td>3215.67</td>
                                    <td>3198.32</td>
                                    <td>3210.74</td>
                                    <td>22,345,678,900</td>
                                    <td>268,901,234,567</td>
                                </tr>
                                <tr>
                                    <td>000001</td>
                                    <td>2023-06-06</td>
                                    <td>3212.56</td>
                                    <td>3234.18</td>
                                    <td>3208.45</td>
                                    <td>3232.76</td>
                                    <td>25,678,901,200</td>
                                    <td>301,234,567,890</td>
                                </tr>
                                <tr>
                                    <td>000001</td>
                                    <td>2023-06-07</td>
                                    <td>3230.12</td>
                                    <td>3238.45</td>
                                    <td>3218.76</td>
                                    <td>3224.21</td>
                                    <td>24,123,456,700</td>
                                    <td>290,876,543,210</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="data-note">
                        <i class="fas fa-info-circle"></i> 数据格式为CSV，编码为GBK。
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 财务数据 -->
        <div class="data-section financial-data">
            <div class="section-header">
                <div class="section-title">
                    <i class="fas fa-file-invoice-dollar"></i> 财务数据
                </div>
                <button class="download-btn">
                    <i class="fas fa-download"></i> 下载数据
                </button>
            </div>
            
            <div class="section-content">
                <div class="data-info">
                    <div class="data-description">
                        提供A股上市公司的季度财务报表数据，包括资产负债表、利润表、现金流量表等核心财务指标，数据覆盖最近20个财务季度。
                    </div>
                    
                    <div class="data-fields">
                        <h4>数据字段说明：</h4>
                        <div class="field-list">
                            <div class="field-item" title="股票代码">stock_code</div>
                            <div class="field-item" title="报表格式">statement_format</div>
                            <div class="field-item" title="报告期">report_date</div>
                            <div class="field-item" title="发布日期">publish_date</div>
                            <div class="field-item" title="货币资金">B_currency_fund@xbx</div>
                            <div class="field-item" title="结算备付金">B_settle_reserves@xbx</div>
                            <div class="field-item" title="营业总收入">R_operating_total_revenue@xbx</div>
                            <div class="field-item" title="营业收入">R_revenue@xbx</div>
                            <div class="field-item" title="利润总额">R_total_profit@xbx</div>
                            <div class="field-item" title="净利润">R_np@xbx</div>
                            <div class="field-item" title="归属于母公司所有者的净利润">R_np_atoopc@xbx</div>
                            <div class="field-item" title="基本每股收益">R_basic_eps@xbx</div>
                            <div class="field-item" title="经营活动产生的现金流量净额">C_ncf_from_oa@xbx</div>
                            <div class="field-item" title="投资活动产生的现金流量净额">C_ncf_from_ia@xbx</div>
                            <div class="field-item" title="筹资活动产生的现金流量净额">C_ncf_from_fa@xbx</div>
                        </div>
                    </div>
                    
                    <div class="data-note">
                        <i class="fas fa-info-circle"></i> 数据为CSV格式，GBK编码，包含大量财务指标字段
                    </div>
                </div>
                
                <div class="data-sample">
                    <h4 class="data-sample-title">数据样例（部分字段）</h4>
                    <div class="data-sample-description">
                        以下为首创股份(600008)2019-2020年部分财务数据
                    </div>
                    <div class="table-responsive">
                        <table class="data-table">
                            <thead>
                                <tr>
                                    <th>股票代码</th>
                                    <th>报表格式</th>
                                    <th>报告期</th>
                                    <th>发布日期</th>
                                    <th>货币资金</th>
                                    <th>营业收入</th>
                                    <th>利润总额</th>
                                    <th>净利润</th>
                                    <th>每股收益</th>
                                    <th>经营活动现金流量</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>sh600008</td>
                                    <td>一般企业</td>
                                    <td>20190331</td>
                                    <td>2019-04-30</td>
                                    <td>5,516,396,276.82</td>
                                    <td>2,448,004,021.45</td>
                                    <td>175,045,798.75</td>
                                    <td>113,581,832.75</td>
                                    <td>0.0204</td>
                                    <td>76,373,602.45</td>
                                </tr>
                                <tr>
                                    <td>sh600008</td>
                                    <td>一般企业</td>
                                    <td>20190630</td>
                                    <td>2019-08-30</td>
                                    <td>4,881,543,669.53</td>
                                    <td>5,748,271,702.29</td>
                                    <td>611,987,024.05</td>
                                    <td>401,322,718.81</td>
                                    <td>0.0564</td>
                                    <td>830,463,534.47</td>
                                </tr>
                                <tr>
                                    <td>sh600008</td>
                                    <td>一般企业</td>
                                    <td>20190930</td>
                                    <td>2019-10-30</td>
                                    <td>3,455,975,038.05</td>
                                    <td>9,153,757,423.83</td>
                                    <td>987,615,798.34</td>
                                    <td>669,583,112.96</td>
                                    <td>0.0995</td>
                                    <td>1,697,087,420.04</td>
                                </tr>
                                <tr>
                                    <td>sh600008</td>
                                    <td>一般企业</td>
                                    <td>20191231</td>
                                    <td>2020-04-02</td>
                                    <td>3,749,504,966.96</td>
                                    <td>14,907,273,552.24</td>
                                    <td>1,598,543,793.89</td>
                                    <td>1,091,511,496.71</td>
                                    <td>0.1686</td>
                                    <td>3,333,386,034.89</td>
                                </tr>
                                <tr>
                                    <td>sh600008</td>
                                    <td>一般企业</td>
                                    <td>20200331</td>
                                    <td>2020-04-30</td>
                                    <td>4,947,224,057.41</td>
                                    <td>2,926,479,447.61</td>
                                    <td>196,238,025.08</td>
                                    <td>108,255,479.59</td>
                                    <td>0.0207</td>
                                    <td>592,814,970.43</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="data-note">
                        <i class="fas fa-info-circle"></i> 财务数据包含大量字段，此处仅展示部分关键指标。完整字段请参考API文档。
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 免责声明和版权信息 -->
    <div class="disclaimer-container">
        <div class="disclaimer-text">
            <strong>免责声明：</strong>本平台提供的数据仅供参考，不构成任何投资建议。投资者据此操作，风险自担。
            我们尽力确保数据的准确性和及时性，但不保证数据的绝对准确、完整和实时。使用本平台数据前，请自行核实。
        </div>
        <div class="copyright">
            © 2023-2024 FinData. All Rights Reserved. 保留所有权利。
        </div>
    </div>
    
    <!-- 登录提示模态框 -->
    <div id="loginModal" class="modal">
        <div class="modal-content">
            <span class="close-btn" onclick="closeModal()">&times;</span>
            <div class="modal-icon">
                <svg viewBox="0 0 24 24" width="48" height="48" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <path d="M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z" stroke="#8a2be2" stroke-width="2"/>
                    <path d="M12 16V12M12 8H12.01" stroke="#8a2be2" stroke-width="2" stroke-linecap="round"/>
                </svg>
            </div>
            <h3 class="modal-title">需要登录</h3>
            <p class="modal-message" id="modalMessage">请先登录后再进行操作</p>
            <div class="modal-buttons">
                <button class="modal-btn cancel-btn" onclick="closeModal()">取消</button>
                <button class="modal-btn login-btn" onclick="goToLogin()">立即登录</button>
            </div>
        </div>
    </div>
    
    <!-- 下载链接模态框 -->
    <div id="downloadModal" class="modal">
        <div class="modal-content download-modal">
            <span class="close-btn" onclick="closeDownloadModal()">&times;</span>
            <div class="modal-icon download-icon">
                <svg viewBox="0 0 24 24" width="48" height="48" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <path d="M12 15V3M12 15L8 11M12 15L16 11M21 15V19C21 19.5304 20.7893 20.0391 20.4142 20.4142C20.0391 20.7893 19.5304 21 19 21H5C4.46957 21 3.96086 20.7893 3.58579 20.4142C3.21071 20.0391 3 19.5304 3 19V15" stroke="#4fc3f7" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
                </svg>
            </div>
            <h3 class="modal-title">数据下载</h3>
            <div class="download-info">
                <p id="downloadFileName" class="download-filename">文件名: stock-trading-data.zip</p>
                <div class="download-link-container">
                    <p>百度网盘链接:</p>
                    <div class="link-input-group">
                        <input type="text" id="baiduLink" class="download-link" readonly>
                        <button class="copy-btn" onclick="copyLink()">
                            <i class="fas fa-copy"></i> 复制
                        </button>
                    </div>
                </div>
                <div class="download-code-container">
                    <p>提取码:</p>
                    <div class="code-input-group">
                        <input type="text" id="extractCode" class="extract-code" readonly>
                        <button class="copy-btn" onclick="copyCode()">
                            <i class="fas fa-copy"></i> 复制
                        </button>
                    </div>
                </div>
            </div>
            <div class="modal-buttons">
                <button class="modal-btn cancel-btn" onclick="closeDownloadModal()">关闭</button>
                <button class="modal-btn download-btn-modal" onclick="openBaiduPan()">
                    <i class="fas fa-external-link-alt"></i> 前往百度网盘
                </button>
            </div>
        </div>
    </div>

    <script>
        // 检查用户是否已登录
        let isLoggedIn = false;
        let userId = null;
        let username = null;
        
        // 百度网盘下载链接
        const downloadLinks = {
            'stock': {
                fileName: 'stock-trading-data.zip',
                link: 'https://pan.baidu.com/s/1Cpm_rgIZ8fbi1W8RqQAaMw?pwd=h5ne',
                code: 'h5ne'
            },
            'index': {
                fileName: 'stock-main-index-data.zip',
                link: 'https://pan.baidu.com/s/1I90UZIrkjgm7MfExkNtc1w?pwd=evax',
                code: 'evax'
            },
            'financial': {
                fileName: 'stock-fin-data-xbx.zip',
                link: 'https://pan.baidu.com/s/1E92yN-Y60dPDp5mT-ap-1Q?pwd=bgpw',
                code: 'bgpw'
            }
        };
        
        // 当前选择的下载类型
        let currentDownloadType = '';
        
        // 页面加载完成后执行
        document.addEventListener('DOMContentLoaded', function() {
            checkLoginStatus();
            
            // 根据当前URL设置导航栏活动项
            setActiveNavItem();
            
            // 为下载按钮添加点击事件
            document.querySelectorAll('.download-btn').forEach((button, index) => {
                button.addEventListener('click', function() {
                    if (isLoggedIn) {
                        // 根据按钮索引确定下载类型
                        const types = ['stock', 'index', 'financial'];
                        showDownloadModal(types[index]);
                    } else {
                        showLoginModal('请先登录后再下载数据');
                    }
                });
            });
            
            // 格式化表格中的大数字
            formatLargeNumbers();
        });
        
        // 设置导航栏活动项
        function setActiveNavItem() {
            const pathname = window.location.pathname;
            const navItems = document.querySelectorAll('.nav-item');
            
            navItems.forEach(item => {
                item.classList.remove('active');
                // 跳过数据按钮，不设置高亮
                if (item.id === 'dataNav') {
                    return;
                }
                
                const href = item.getAttribute('href');
                // 跳过javascript:void(0)这种特殊链接
                if (href && href.startsWith('/')) {
                    // 处理根路径特殊情况
                    if (href === '/' && pathname === '/') {
                        item.classList.add('active');
                    }
                    // 处理其他路径，使用精确匹配或前缀匹配
                    else if (href !== '/' && (pathname === href || pathname.startsWith(href + '/'))) {
                        item.classList.add('active');
                    }
                }
            });
        }
        
        // 显示下载模态框
        function showDownloadModal(type) {
            currentDownloadType = type;
            
            // 显示加载中状态
            document.getElementById('downloadFileName').textContent = '加载中...';
            document.getElementById('baiduLink').value = '';
            document.getElementById('extractCode').value = '';
            document.getElementById('downloadModal').style.display = 'flex';
            
            // 从API获取最新链接信息
            fetch(`/api/data/baidu-links/${type}`)
                .then(response => {
                    if (!response.ok) {
                        throw new Error('获取链接信息失败');
                    }
                    return response.json();
                })
                .then(data => {
                    // 更新下载信息
                    document.getElementById('downloadFileName').textContent = '文件名: ' + data.fileName;
                    document.getElementById('baiduLink').value = data.link;
                    document.getElementById('extractCode').value = data.code;
                    
                    // 更新本地缓存
                    downloadLinks[type] = {
                        fileName: data.fileName,
                        link: data.link,
                        code: data.code
                    };
                })
                .catch(error => {
                    console.error('获取链接信息失败:', error);
                    
                    // 如果API获取失败，使用本地缓存的链接
                    const downloadInfo = downloadLinks[type];
                    document.getElementById('downloadFileName').textContent = '文件名: ' + downloadInfo.fileName;
                    document.getElementById('baiduLink').value = downloadInfo.link;
                    document.getElementById('extractCode').value = downloadInfo.code;
                });
        }
        
        // 关闭下载模态框
        function closeDownloadModal() {
            document.getElementById('downloadModal').style.display = 'none';
        }
        
        // 复制百度网盘链接
        function copyLink() {
            const linkInput = document.getElementById('baiduLink');
            linkInput.select();
            document.execCommand('copy');
            
            // 显示复制成功提示
            const copyBtn = event.target;
            const originalText = copyBtn.textContent;
            copyBtn.textContent = '已复制!';
            copyBtn.style.backgroundColor = '#4CAF50';
            
            setTimeout(() => {
                copyBtn.textContent = originalText;
                copyBtn.style.backgroundColor = '';
            }, 1500);
        }
        
        // 复制提取码
        function copyCode() {
            const codeInput = document.getElementById('extractCode');
            codeInput.select();
            document.execCommand('copy');
            
            // 显示复制成功提示
            const copyBtn = event.target;
            const originalText = copyBtn.textContent;
            copyBtn.textContent = '已复制!';
            copyBtn.style.backgroundColor = '#4CAF50';
            
            setTimeout(() => {
                copyBtn.textContent = originalText;
                copyBtn.style.backgroundColor = '';
            }, 1500);
        }
        
        // 打开百度网盘链接
        function openBaiduPan() {
            const link = document.getElementById('baiduLink').value;
            window.open(link, '_blank');
        }
        
        // 格式化大数字
        function formatLargeNumbers() {
            const numberCells = document.querySelectorAll('.data-table td:nth-child(n+4)');
            
            numberCells.forEach(cell => {
                const text = cell.textContent.trim().replace(/,/g, '');
                const value = parseFloat(text);
                
                // 如果是有效数字
                if (!isNaN(value)) {
                    // 添加数字格式化类
                    cell.classList.add('number-large');
                    
                    // 根据数字大小进行不同格式化
                    if (value >= 100000000) {
                        // 亿级别，显示为 x.xx亿
                        cell.textContent = (value / 100000000).toFixed(2) + '亿';
                    } else if (value >= 10000) {
                        // 万级别，显示为 x.xx万
                        cell.textContent = (value / 10000).toFixed(2) + '万';
                    } else {
                        // 普通数字，添加千分位分隔符
                        cell.textContent = value.toLocaleString('zh-CN', {
                            minimumFractionDigits: 2,
                            maximumFractionDigits: 2
                        });
                    }
                }
            });
        }
        
        // 检查用户登录状态
        function checkLoginStatus() {
            fetch('/api/user-info')
                .then(response => {
                    if (response.status === 200) {
                        isLoggedIn = true;
                        return response.json();
                    } else {
                        isLoggedIn = false;
                        throw new Error('未登录');
                    }
                })
                .then(data => {
                    userId = data.UserId;
                    username = data.username;
                    
                    // 更新导航栏
                    document.getElementById('loginNav').style.display = 'none';
                    document.getElementById('dashboardNav').style.display = 'block';
                })
                .catch(error => {
                    console.log('未登录或获取用户信息失败:', error);
                });
        }
        
        // 检查登录状态并跳转到回测页面或显示登录提示
        function checkLoginForBacktest() {
            if (isLoggedIn) {
                // 已登录，跳转到回测页面
                window.location.href = '/backtest';
            } else {
                // 未登录，显示登录提示模态框
                showLoginModal('请先登录以使用回测功能');
            }
        }
        
        // 显示登录提示模态框
        function showLoginModal(message) {
            document.getElementById('modalMessage').textContent = message || '请先登录后再进行操作';
            document.getElementById('loginModal').style.display = 'flex';
        }
        
        // 关闭登录提示模态框
        function closeModal() {
            document.getElementById('loginModal').style.display = 'none';
        }
        
        // 跳转到登录页面
        function goToLogin() {
            // 获取当前模态框消息，判断是否为回测相关
            const modalMessage = document.getElementById('modalMessage').textContent;
            if (modalMessage.includes('回测')) {
                window.location.href = '/login?redirect=/backtest';
            } else {
                window.location.href = '/login';
            }
        }
    </script>
</body>
</html> 